<?php include "antet.php"; include "func.php";

if (isset($_SESSION["user"][0], $_GET["page"]))
{
	$_GET["page"]=clean($_GET["page"]);
	$reports=reports($_SESSION["user"][0]);
	$town=town($_GET["town"]);
 $lim=explode("-", $town[11]);
$res=explode("-", $town[10]);
$prod=explode("-", $town[9]);
}
else {header('Location: login.php'); die();}
kepala($title." - ".$lang['reports'].$_SESSION["user"][0]);
?>
<script type="text/javascript">
var res_start0=<?php echo floor($res[0]);?>;var res_start1=<?php echo floor($res[1]);?>;var res_start2=<?php echo floor($res[2]);?>;var res_start3=<?php echo floor($res[3]);?>;var res_start4=<?php echo floor($res[4]);?>;
var res_limit0=<?php echo $lim[0];?>;var res_limit1=<?php echo $lim[1];?>;var res_limit2=<?php echo $lim[1];?>;var res_limit3=<?php echo $lim[1];?>;var res_limit4=<?php echo $lim[2];?>;
var res_ph0=<?php echo ($prod[0]-$town[3]-$town[12]);?>;var res_ph1=<?php echo ($prod[1]);?>;var res_ph2=<?php echo ($prod[2]);?>;var res_ph3=<?php echo ($prod[3]);?>;var res_ph4=<?php echo ($prod[4]);?>;
var res_sec0=0;var res_sec1=0;var res_sec2=0;var res_sec3=0;var res_sec4=0;
</script>
<?php
/*<table class="table table-hover table-bordered">
	<tr>
		<td>'.$lang["subject"].'</td>
		<td>'.$lang["sentAt"].'</td>
		<td>'.$lang["delete"].'</td>
	</tr></table>*/
$output = BlankHeader($town, $lim, "Reports","Recent happening in your empire.","report.png");
$output .= '
<div class="row">
	<div class="col-sm-4">
	'.ads(1,"reportslist").'
	</div>
	<div class="col-sm-8">
		<ul class="list-group">';
for ($i=$_GET["page"]*10; $i<$_GET["page"]*10+10; $i++)
			{
			 if (isset($reports[$i]))
				{
			if ($reports[$i][5])
					{ $output .= '<li class="success"><span class="label label-success">'.$reports[$i][4].'</span> [new] ';}
					else
					{$output .= '<li class="list-group-item list-group-item-success"><span class="label label-default">'.$reports[$i][4].'</span> ';}
$output .= '<a type="button" class="close" aria-hidden="true" href="delrep.php?id='.$reports[$i][0].'&town='.$_GET["town"].'">&times;</a>
 <a class="q_link" href="msg_view.php?type=0&id='.$reports[$i][0].'&town='.$_GET["town"].'">'.$reports[$i][2].'</a></li>';
				}
			}
$output .= '</ul>';
	$output .= '<ul class="pagination">';
for ($i=$_GET["page"]-10; $i<=$_GET["page"]-1; $i++) 
{
	if ($i>=0) 
	{
	$output .= '<li><a class="q_link" href="reports.php?page='.$i.'&town='.$_GET["town"].'">'.$i.'</a></li>';
	}
}
	$output .=  "\n".'<li class="active"><a href="#">'.$_GET["page"].'<span class="sr-only">(current)</span></a></li>';
		for ($i=$_GET["page"]+1; $i<$_GET["page"]+10; $i++) 
		{
			if ($i<ceil(count($reports)/10)) 
			{
			$output .= "\n".'<li><a class="q_link" href="reports.php?page='.$i.'&town='.$_GET["town"].'">'.$i.'</a></li>';
			}
		}
			$output .= "\n".'<li><a href="delallrep.php?town='.$_GET["town"].'"><span class="label label-danger">'.$lang["deleteAll"].'</span></a></li></ul>'; 

$output .= '
		</div>
	</div>';		
	$output .= ads(1,"bottom");
		$output .= about(); 
		echo $output;
?>
